import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt, pyqtSignal

class SlaveTraitCell(QtGui.QPushButton):
	def __init__(self, *args, **kw):
		QtGui.QPushButton.__init__(self, *args, **kw)
		self.setGeometry(0, 0, 200, 42)
		font = QtGui.QFont("Gabrielle", 18)
		self.setFont(font)
		self.setStyleSheet(SlaveTraitCell.cell_style)
		self.desc = ""

	mouse_in = pyqtSignal(bool)
	mouse_out = pyqtSignal(bool)

	def enterEvent(self, event):
		self.mouse_in.emit(True)

	def leaveEvent(self, event):
		self.mouse_out.emit(True)


	cell_style = """
		QPushButton {
			border : 0;
			color : black;
			background-image : url("resources/slave_market_trait_cell.png")
		}
		QPushButton:hover {
			color : maroon;
		}
		QPushButton:pressed {
			padding-top	: 3px;
			padding-left	: 3px;
			background-image : url("resources/slave_market_trait_cell_down.png")
		}

	"""


if __name__ == "__main__":
	cell = None
	def min(thing):
		cell.setText("Hover")
	def mout(thing):
		cell.setText("Normal")

	app = QtGui.QApplication(sys.argv)

	font_db = QtGui.QFontDatabase()
	font_db.addApplicationFont("resources/Gabrielle.ttf")

	path = "resources/wood.jpg"
	top = QtGui.QLabel()
	top.setPixmap(QtGui.QPixmap(path))
	top.setGeometry(0, 0, 1024, 768)

	cell = SlaveTraitCell(top)
	cell.move(20, 20)
	cell.mouse_in.connect(min)
	cell.mouse_out.connect(mout)

	top.show()
	sys.exit(app.exec_())

